package com.tkm.expressions.eg

fun main() {
    println("HelloWorld" - "World")
    println("HelloWorld" * 2)
    println("HelloWorld" / 3)
    println("HelloWorld" / "l")
}

operator fun String.minus(subString: String): String {
    val index = this.indexOf(subString)
    if (index == -1) {
        return this
    }
    return this.substring(0, index)
}

operator fun String.times(number: Int): String {
    return (1..number).joinToString("") { it.toString() }
}

operator fun String.div(right: Any): Int {
    return this.windowed(right.toString().length, 1) {
        it == right
    }.count { it }
}
